package com.autoplaza;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

public class RefinarBusqueda extends Activity {
	Button modelo, marca, version, ano, ubicacion, precio, transmision, color, financiamiento;
	SharedPreferences preferences;
	boolean metodo;
	StringBuilder sb1, sb2, sb3, sb4, sb5,sb6,sb7,sb8,sb10;
	String modeloconcate, marcaconcate,anoconcate, ubicaconcate, sb9;
	int var=0,var2;
	private String textoEnviar2,textoEnviar3;
	private String cadena2,cadena3,cadena4;

	@Override
	public void onBackPressed() {
		super.onBackPressed();
		Log.i("onback", "onback");
		String url=funcionUrl();
		Intent resultados = new Intent(RefinarBusqueda.this, Resultados.class);
		resultados.putExtra("sb9", url);
		startActivity(resultados);
	}
	
	private String funcionUrl() {
		StringBuilder sb = new StringBuilder();
		sb.append("http://iphone.autoplaza.com.mx/fastSearch/fastSearchIphone.aspx?querybiphone=yes&BusqMult=");
		SharedPreferences preferences= getSharedPreferences("Carro",Context.MODE_PRIVATE);
		if(!(preferences.getString("marca", "")).equals("[Cualquiera]")){
			sb.append(":marca;"+preferences.getString("marca", "").replaceAll(" ", "%20"));
		}
		if(!(preferences.getString("modelo", "")).equals("[Cualquiera]")){
			sb.append(":modelo;"+preferences.getString("modelo", "").replaceAll(" ", "%20"));
		}
		if(!(preferences.getString("ano", "")).equals("[Cualquiera]")){
			sb.append(":year;"+preferences.getString("ano", "").replaceAll(" ", "%20"));
		}
		if(!(preferences.getString("ubicacion", "")).equals("[Cualquiera]")){
			sb.append(":estado;"+preferences.getString("ubicacion", "").replaceAll(" ", "%20"));
		}
		if(!(preferences.getString("precio", "")).equals("[Cualquiera]")){
			sb.append(":rankprecio;"+preferences.getString("precio", "").replaceAll(" ", "%20"));
		}
		if(!(preferences.getString("transmision", "")).equals("[Cualquiera]")){
			sb.append(":tipotransmision;"+preferences.getString("transmision", "").replaceAll(" ", "%20"));
		}
		if(!(preferences.getString("color", "")).equals("[Cualquiera]")){
			sb.append(":colorexterior;"+preferences.getString("color", "").replaceAll(" ", "%20"));
		}
		if(!(preferences.getString("financiamiento", "[Cualquiera]")).equals("[Cualquiera]")){
			sb.append(":tieneplanfid;"+preferences.getString("financiamiento", "").replaceAll(" ", "%20"));
		}
		if(!(preferences.getString("version", "")).equals("[Cualquiera]")){
			sb.append(":version;"+preferences.getString("version", "").replaceAll(" ", "%20"));
		}
		sb.append("&titlebiphone=yes&offset=0&hits=10&VIP=yes");
		Log.i("CADENA BUSQUEDA", ""+sb.toString());
		return sb.toString();
	}

	@Override
	protected void onPause() {
		super.onPause();
		SharedPreferences preferences= getSharedPreferences("Carro",Context.MODE_PRIVATE);
		SharedPreferences.Editor editor=preferences.edit();
		editor.putString("marca", marca.getText().toString().trim());
		editor.putString("modelo", modelo.getText().toString().trim());
		editor.putString("ano", ano.getText().toString().trim());
		editor.putString("ubicacion", ubicacion.getText().toString().trim());
		editor.putString("precio", precio.getText().toString().trim());
		editor.putString("transmision", transmision.getText().toString().trim());
		editor.putString("color", color.getText().toString().trim());

		int fi=99;
		if(financiamiento.getText().toString().trim().equals("Sin Plan de Financiamiento")){
			fi=0;
			editor.putString("financiamiento", ""+fi);
		}else if(financiamiento.getText().toString().trim().equals("Con Plan de Financiamiento")){
			fi=1;
			editor.putString("financiamiento", ""+fi);
		}else if(financiamiento.getText().toString().trim().equals("[Cualquiera]")){
			editor.putString("financiamiento", "[Cualquiera]");
		}

		//		editor.putString("financiamiento", ""+fi);

		editor.commit();

	}


	//Método OnResume
	@Override
	protected void onResume() {
		super.onResume();
		Log.i("onresume", "onresume");
		SharedPreferences preferences= getSharedPreferences("Carro",Context.MODE_PRIVATE);


		marca.setText(preferences.getString("marca", "[Cualquiera]"));
		modelo.setText(preferences.getString("modelo", "[Cualquiera]"));
		ano.setText(preferences.getString("ano", "[Cualquiera]"));
		ubicacion.setText(preferences.getString("ubicacion", "[Cualquiera]"));
		precio.setText(preferences.getString("precio", "[Cualquiera]"));
		transmision.setText(preferences.getString("transmision", "[Cualquiera]"));
		color.setText(preferences.getString("color", "[Cualquiera]"));

		if(preferences.getString("financiamiento", "[Cualquiera]").equals("0")){
			financiamiento.setText("Sin Plan de Financiamiento");

		}else if(preferences.getString("financiamiento", "[Cualquiera]").equals("1")){
			financiamiento.setText("Con Plan de Financiamiento");

		}
		//	financiamiento.setText(preferences.getString("financiamiento", "[Cualquiera]"));
		version.setText(preferences.getString("version", "[Cualquiera]"));
		Log.d("Buscar",preferences.getString("modelo", "no hay nada"));
		Log.d("BuscarMarca",preferences.getString("marca", "no hay nada"));
		metodo = isOnline();
		if(metodo==false){
			AlertDialog.Builder builder = new AlertDialog.Builder(this);
			builder.setMessage("Necesita conexión a internet")
			.setCancelable(false)
			.setPositiveButton("Aceptar", new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface dialog, int id) {
				}
			});
			AlertDialog alertDialog = builder.create();
			alertDialog.show();

		}
	}

	
	public void actualizar(View view){
		onBackPressed();
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.refinarbusqueda);
		int size = Utils.getScreenSize2(RefinarBusqueda.this);
		if( size == 1){
			RelativeLayout lin = (RelativeLayout) findViewById(R.id.linearLayout1);
			lin.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 30));
//			btnmenu.setLayoutParams(new LinearLayout.LayoutParams(30, 30));
		}		
		if( size == 2){
			RelativeLayout lin = (RelativeLayout) findViewById(R.id.linearLayout1);
			lin.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 60));	
//			btnmenu.setLayoutParams(new LinearLayout.LayoutParams(45, 45));

		}		
		if( size == 3){
			RelativeLayout lin = (RelativeLayout) findViewById(R.id.linearLayout1);
			lin.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 80));
//			btnmenu.setLayoutParams(new LinearLayout.LayoutParams(80, 80));

		}

		Bundle extras=getIntent().getExtras();
		if(extras != null){
			sb9 = extras.getString("sb9");
			Log.i("Consulta Refinar", ""+sb9);
		}

		preferences= getSharedPreferences("Carro",Context.MODE_PRIVATE);
		modelo = (Button) findViewById(R.id.rmodelo);
		marca = (Button) findViewById(R.id.rmarca);
		version = (Button) findViewById(R.id.rversion);
		ano = (Button) findViewById(R.id.ryear);
		ubicacion = (Button) findViewById(R.id.restado);
		precio= (Button) findViewById(R.id.rprecio);
		transmision = (Button) findViewById(R.id.rtrans);
		color = (Button) findViewById(R.id.rcolor);
		financiamiento = (Button) findViewById(R.id.rfinan);

		//Valores por defecto de los botones
		marca.setText(preferences.getString("marca", "[Cualquiera]"));
		modelo.setText(preferences.getString("modelo", "[Cualquiera]"));
		version.setText(preferences.getString("version", "[Cualquiera]"));
		ano.setText(preferences.getString("ano", "[Cualquiera]"));
		ubicacion.setText(preferences.getString("ubicacion", "[Cualquiera]"));
		precio.setText(preferences.getString("precio", "[Cualquiera]"));
		transmision.setText(preferences.getString("transmision", "[Cualquiera]"));
		color.setText(preferences.getString("color", "[Cualquiera]"));
		financiamiento.setText(preferences.getString("financiamiento", "[Cualquiera]"));

		marca.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				metodo = isOnline();
				if(metodo==false){
					AlertDialog.Builder builder = new AlertDialog.Builder(RefinarBusqueda.this);
					builder.setMessage("Necesita conexión a internet")
					.setCancelable(false)
					.setPositiveButton("Aceptar", new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int id) {
						}
					});
					AlertDialog alertDialog = builder.create();
					alertDialog.show();

				}else{
					String marcasb1 = metodomarca();
					Intent in = new Intent(RefinarBusqueda.this, ListaMarca.class);
					in.putExtra("sb1", ""+marcasb1); //la consulta de la marca
					in.putExtra("sb9", sb9); //mi consulta
					in.putExtra("bandera", 7);

					//colocar desde cero las demas 
					//	SharedPreferences preferences= getSharedPreferences("Carro",Context.MODE_PRIVATE);
					//	SharedPreferences.Editor editor = preferences.edit();
					//	editor.clear(); //marca modelo, ano ubicacion, precio
					//	editor.remove("modelo").remove("ano").remove("ubicacion").remove("precio");
					//	editor.commit();
					//	in.putExtra("content", ""+content.getText().toString().trim());
					startActivity(in);
				}
			}
		});

		modelo.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				metodo = isOnline();
				if(metodo==false){
					AlertDialog.Builder builder = new AlertDialog.Builder(RefinarBusqueda.this);
					builder.setMessage("Necesita conexión a internet")
					.setCancelable(false)
					.setPositiveButton("Aceptar", new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int id) {
						}
					});
					AlertDialog alertDialog = builder.create();
					alertDialog.show();

				}else{
					if(marca.getText().toString().equals("[Cualquiera]")){
						final Dialog dialog = new Dialog(RefinarBusqueda.this);
						dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
						dialog.setContentView(R.layout.rowcustom);
						Button btn = (Button) dialog.findViewById(R.id.cancel);
						btn.setOnClickListener(new OnClickListener() {
							@Override
							public void onClick(View v) {
								dialog.cancel();
							}
						});
						dialog.show();
					}else{
						String modelosb2 = metodomodelo();
						Intent in = new Intent(RefinarBusqueda.this, ListaModelo.class);

						in.putExtra("sb9", sb9); //mi consulta
						in.putExtra("bandera", 7);
						in.putExtra("sb2", ""+modelosb2);
						//	in.putExtra("content", ""+content.getText().toString().trim());
						startActivity(in);
					}
				}
			}
		});

		version.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				metodo = isOnline();
				if(metodo==false){
					AlertDialog.Builder builder = new AlertDialog.Builder(RefinarBusqueda.this);
					builder.setMessage("Necesita conexión a internet")
					.setCancelable(false)
					.setPositiveButton("Aceptar", new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int id) {
						}
					});
					AlertDialog alertDialog = builder.create();
					alertDialog.show();

				}else{
					if(modelo.getText().toString().equals("[Cualquiera]")){
						final Dialog dialog = new Dialog(RefinarBusqueda.this);
						dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
						dialog.setContentView(R.layout.rowcustom4);
						Button btn = (Button) dialog.findViewById(R.id.cancel);
						btn.setOnClickListener(new OnClickListener() {
							@Override
							public void onClick(View v) {
								dialog.cancel();
							}
						});
						dialog.show();
					}else{
						String modelosb2 = metodoversion();
						Intent in = new Intent(RefinarBusqueda.this, ListaVersion.class);
						in.putExtra("bandera", 7);
						in.putExtra("sb9", sb9); //mi consulta
						in.putExtra("sb2", ""+modelosb2);
						//	in.putExtra("content", ""+content.getText().toString().trim());
						startActivity(in);
					}
				}
			}
		});

		ano.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				metodo = isOnline();
				if(metodo==false){
					AlertDialog.Builder builder = new AlertDialog.Builder(RefinarBusqueda.this);
					builder.setMessage("Necesita conexión a internet")
					.setCancelable(false)
					.setPositiveButton("Aceptar", new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int id) {
						}
					});
					AlertDialog alertDialog = builder.create();
					alertDialog.show();

				}else{
					String anosb3 = metodoano();
					Intent in = new Intent(RefinarBusqueda.this, ListaAno.class);
					in.putExtra("bandera", 7);
					in.putExtra("sb9", sb9); //mi consulta
					in.putExtra("sb3", ""+anosb3);
					//	in.putExtra("content", ""+content.getText().toString().trim());
					startActivity(in);
				}
			}
		});



		ubicacion.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v){
				metodo = isOnline();
				if(metodo==false){
					AlertDialog.Builder builder = new AlertDialog.Builder(RefinarBusqueda.this);
					builder.setMessage("Necesita conexión a internet")
					.setCancelable(false)
					.setPositiveButton("Aceptar", new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int id) {
						}
					});
					AlertDialog alertDialog = builder.create();
					alertDialog.show();

				}else{
					String ubicacionsb4 = metodoubica();
					Intent in=new Intent(RefinarBusqueda.this, ListaUbicacion.class);
					in.putExtra("bandera", 7);
					in.putExtra("sb9", sb9); //mi consulta

					in.putExtra("sb4", ""+ubicacionsb4);
					//	in.putExtra("content", ""+content.getText().toString().trim());
					startActivity(in);
				}
			}
		});

		precio.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				metodo = isOnline();
				if(metodo==false){
					AlertDialog.Builder builder = new AlertDialog.Builder(RefinarBusqueda.this);
					builder.setMessage("Necesita conexión a internet")
					.setCancelable(false)
					.setPositiveButton("Aceptar", new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int id) {
						}
					});
					AlertDialog alertDialog = builder.create();
					alertDialog.show();

				}else{
					String preciosb5 = metodoprecio();
					Intent in = new Intent(RefinarBusqueda.this, ListaPrecio.class);
					in.putExtra("bandera", 7);
					in.putExtra("sb9", sb9); //mi consulta

					in.putExtra("sb5", ""+preciosb5);
					//	in.putExtra("content", ""+content.getText().toString().trim());
					startActivity(in);
				}
			}
		});

		transmision.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				metodo = isOnline();
				if(metodo==false){
					AlertDialog.Builder builder = new AlertDialog.Builder(RefinarBusqueda.this);
					builder.setMessage("Necesita conexión a internet")
					.setCancelable(false)
					.setPositiveButton("Aceptar", new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int id) {
						}
					});
					AlertDialog alertDialog = builder.create();
					alertDialog.show();

				}else{
					String transmisionb5 = metodotransmision();
					Intent in = new Intent(RefinarBusqueda.this, ListaTransmision.class);
					in.putExtra("bandera", 7);
					in.putExtra("sb9", sb9); //mi consulta

					in.putExtra("sb7", ""+transmisionb5);
					//	in.putExtra("content", ""+content.getText().toString().trim());
					startActivity(in);
				}
			}
		});

		color.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				metodo = isOnline();
				if(metodo==false){
					AlertDialog.Builder builder = new AlertDialog.Builder(RefinarBusqueda.this);
					builder.setMessage("Necesita conexión a internet")
					.setCancelable(false)
					.setPositiveButton("Aceptar", new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int id) {
						}
					});
					AlertDialog alertDialog = builder.create();
					alertDialog.show();

				}else{
					String colorb5 = metodocolor();
					Intent in = new Intent(RefinarBusqueda.this, ListaColor.class);
					in.putExtra("bandera", 7);
					in.putExtra("sb9", sb9); //mi consulta

					in.putExtra("sb8", ""+colorb5);
					//	in.putExtra("content", ""+content.getText().toString().trim());
					startActivity(in);
				}
			}
		});

		financiamiento.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				metodo = isOnline();
				if(metodo==false){
					AlertDialog.Builder builder = new AlertDialog.Builder(RefinarBusqueda.this);
					builder.setMessage("Necesita conexión a internet")
					.setCancelable(false)
					.setPositiveButton("Aceptar", new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int id) {
						}
					});
					AlertDialog alertDialog = builder.create();
					alertDialog.show();

				}else{
					String financiamientob5 = metodofinanciamiento();
					Intent in = new Intent(RefinarBusqueda.this, ListaFinanciamiento.class);
					in.putExtra("bandera", 7);
					in.putExtra("sb9", sb9); //mi consulta

					in.putExtra("sb10", ""+financiamientob5);
					//	in.putExtra("content", ""+content.getText().toString().trim());
					startActivity(in);
				}
			}
		});
	}

	//CHECA LA CONEXION A INTERNET
	public boolean isOnline() {
		NetworkInfo networkInfo = ((ConnectivityManager) getApplicationContext()
				.getSystemService(Context.CONNECTIVITY_SERVICE))
				.getActiveNetworkInfo();

		if(networkInfo == null || !networkInfo.isConnected()) {
			return false;
		}
		return true;
	}


	//Metodos de seleccion para cada opción//
	//Metodo para la marca
	//	public String metodomarca(){
	//	var=0;
	//	sb1= new StringBuilder();
	//	marcaconcate ="http://iphone.autoplaza.com.mx/fastSearch/fastSearchIphone.aspx?isnavigator=yes&navigatorname=marca&query=";
	//	StringBuilder sb = new StringBuilder();
	//	sb1.append(marcaconcate);
	//	Log.i("URL", sb1.toString());
	////	Toast.makeText(getApplicationContext(), ""+sb1.toString(), Toast.LENGTH_LONG).show();
	//	return sb1.toString();
	//	
	//	}


	//Metodo para la marca

	public String metodomarca(){

		var=0;

		marcaconcate ="http://iphone.autoplaza.com.mx/fastSearch/fastSearchIphone.aspx?isnavigator=yes&navigatorname=marca&query=";

		StringBuilder sbpor = new StringBuilder();

		sb1 = new StringBuilder();
		sb1.append(marcaconcate);

		if(!modelo.getText().toString().equals("[Cualquiera]")){

			sb1.append("modelo;");

			try {

				textoEnviar2 = URLEncoder.encode(modelo.getText().toString(), "utf-8");

			} catch (UnsupportedEncodingException e1) {

				// TODO Auto-generated catch block

				e1.printStackTrace();

			}

			char[] array6= textoEnviar2.toCharArray();

			for(int i=0; i<array6.length;i++){

				if(array6[i]=='+'){

					array6[i]='_';

				}

			}

			for(int i=0;i<array6.length;i++){

				sbpor.append(array6[i]);

			}

			cadena2= sbpor.toString();


			sb1.append(cadena2);

			var=1;

		}

		if(!ano.getText().toString().equals("[Cualquiera]")){

			StringBuilder anoepor = new StringBuilder();

			if(var==1){

				sb1.append(":");

			}

			sb1.append("year;");

			try {

				textoEnviar2 = URLEncoder.encode(ano.getText().toString(), "utf-8");

			} catch (UnsupportedEncodingException e1) {

				// TODO Auto-generated catch block

				e1.printStackTrace();

			}

			char[] array6= textoEnviar2.toCharArray();

			for(int i=0; i<array6.length;i++){

				if(array6[i]=='+'){

					array6[i]='_';

				}

			}

			for(int i=0;i<array6.length;i++){

				anoepor.append(array6[i]);

			}

			cadena2= anoepor.toString();


			sb1.append(cadena2);

			var=2;

		}

		if(!ubicacion.getText().toString().equals("[Cualquiera]")){

			StringBuilder ubipor = new StringBuilder();

			if(var==1){


				sb1.append(":");

			}

			if(var==2){


				sb1.append(":");

			}

			sb1.append("estado;");

			try {

				textoEnviar2 = URLEncoder.encode(ubicacion.getText().toString(), "utf-8");

			} catch (UnsupportedEncodingException e1) {

				// TODO Auto-generated catch block

				e1.printStackTrace();

			}

			char[] array6= textoEnviar2.toCharArray();

			for(int i=0; i<array6.length;i++){

				if(array6[i]=='+'){

					array6[i]='_';

				}

			}

			for(int i=0;i<array6.length;i++){

				ubipor.append(array6[i]);

			}

			cadena2= ubipor.toString();


			sb1.append(cadena2);

			var=3;

		}

		if(!precio.getText().toString().equals("[Cualquiera]")){

			StringBuilder prepor = new StringBuilder();

			if(var==1){


				sb1.append(":");

			}

			if(var==2){



				sb1.append(":");

			}else

				if(var==3){


					sb1.append(":");

				}

			sb1.append("rankprecio;");

			try {

				textoEnviar2 = URLEncoder.encode(precio.getText().toString(), "utf-8");

			} catch (UnsupportedEncodingException e1) {

				// TODO Auto-generated catch block

				e1.printStackTrace();

			}

			char[] array6= textoEnviar2.toCharArray();

			for(int i=0; i<array6.length;i++){

				if(array6[i]=='+'){

					array6[i]='_';

				}

			}

			for(int i=0;i<array6.length;i++){

				prepor.append(array6[i]);

			}

			cadena2= prepor.toString();

			sb1.append(cadena2);

			var=4;

		}

		if(!version.getText().toString().equals("[Cualquiera]")){

			StringBuilder spreciob = new StringBuilder();

			if(var==1){

				sb1.append(":");

			}

			if(var==2){

				sb1.append(":");

			}

			if(var==3){

				sb1.append(":");

			}

			if(var==4){

				sb1.append(":");

			}

			sb1.append("version;");

			try {

				textoEnviar2 = URLEncoder.encode(version.getText().toString(), "utf-8");

			} catch (UnsupportedEncodingException e1) {

				e1.printStackTrace();

			}

			char[] array6= textoEnviar2.toCharArray();

			for(int i=0; i<array6.length;i++){

				if(array6[i]=='+'){

					array6[i]='_';

				}

			}

			for(int i=0;i<array6.length;i++){

				spreciob.append(array6[i]);

			}

			cadena2= spreciob.toString();


			sb1.append(cadena2);

			var=5;

		}

		if(!transmision.getText().toString().equals("[Cualquiera]")){

			StringBuilder spreciob = new StringBuilder();

			if(var==1){

				sb1.append(":");

			}

			if(var==2){

				sb1.append(":");

			}

			if(var==3){

				sb1.append(":");

			}

			if(var==4){

				sb1.append(":");

			}

			if(var==5){

				sb1.append(":");

			}

			sb1.append("tipotransmision;");

			try {

				textoEnviar2 = URLEncoder.encode(transmision.getText().toString(), "utf-8");

			} catch (UnsupportedEncodingException e1) {

				e1.printStackTrace();

			}

			char[] array6= textoEnviar2.toCharArray();

			for(int i=0; i<array6.length;i++){

				if(array6[i]=='+'){

					array6[i]='_';

				}

			}

			for(int i=0;i<array6.length;i++){

				spreciob.append(array6[i]);

			}

			cadena2= spreciob.toString();


			sb1.append(cadena2);

			var=6;

		}

		if(!color.getText().toString().equals("[Cualquiera]")){

			StringBuilder spreciob = new StringBuilder();

			if(var==1){

				sb1.append(":");

			}

			if(var==2){

				sb1.append(":");

			}

			if(var==3){

				sb1.append(":");

			}

			if(var==4){

				sb1.append(":");

			}

			if(var==5){

				sb1.append(":");

			}

			if(var==6){

				sb1.append(":");

			}

			sb1.append("colorexterior;");

			try {

				textoEnviar2 = URLEncoder.encode(color.getText().toString(), "utf-8");

			} catch (UnsupportedEncodingException e1) {

				e1.printStackTrace();

			}

			char[] array6= textoEnviar2.toCharArray();

			for(int i=0; i<array6.length;i++){

				if(array6[i]=='+'){

					array6[i]='_';

				}

			}

			for(int i=0;i<array6.length;i++){

				spreciob.append(array6[i]);

			}

			cadena2= spreciob.toString();


			sb1.append(cadena2);

			var=7;

		}

		if(!financiamiento.getText().toString().equals("[Cualquiera]")){

			StringBuilder spreciob = new StringBuilder();

			if(var==1){

				sb1.append(":");

			}

			if(var==2){

				sb1.append(":");

			}

			if(var==3){

				sb1.append(":");

			}

			if(var==4){

				sb1.append(":");

			}

			if(var==5){

				sb1.append(":");

			}

			if(var==6){

				sb1.append(":");

			}

			if(var==7){

				sb1.append(":");

			}

			sb1.append("tieneplanfid;");

			try {

				textoEnviar2 = URLEncoder.encode(financiamiento.getText().toString(), "utf-8");

			} catch (UnsupportedEncodingException e1) {

				e1.printStackTrace();

			}

			char[] array6= textoEnviar2.toCharArray();

			for(int i=0; i<array6.length;i++){

				if(array6[i]=='+'){

					array6[i]='_';

				}

			}

			for(int i=0;i<array6.length;i++){

				spreciob.append(array6[i]);

			}

			cadena2= spreciob.toString();
			int finanid=99;
			if(cadena2.equals("Sin_Plan_de_Financiamiento")){
				finanid=0;
			}else if(cadena2.equals("Con_Plan_de_Financiamiento")){
				finanid=1;

			}


			sb1.append(finanid);

			var=8;

		}

		Log.i("URL", sb1.toString());

		return sb1.toString();

	}

	//Para la modelo
	public String metodomodelo(){
		sb2= new StringBuilder();
		var=0;
		modeloconcate ="http://iphone.autoplaza.com.mx/fastSearch/fastSearchIphone.aspx?isnavigator=yes&navigatorname=modelo&query=";
		StringBuilder sbpor = new StringBuilder();
		sb2.append(modeloconcate);
		if(!marca.getText().toString().equals("[Cualquier marca: ]")){
			sb2.append("marca;");
			try {
				textoEnviar2 = URLEncoder.encode(marca.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				sbpor.append(array6[i]);
			}
			cadena2= sbpor.toString();

			sb2.append(cadena2);	
			var=1;
		}
		if(!ano.getText().toString().equals("[Cualquiera]")){
			StringBuilder anoepor = new StringBuilder();
			if(var==1){
				sb2.append(":");
			}
			sb2.append("year;");
			try {
				textoEnviar2 = URLEncoder.encode(ano.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				anoepor.append(array6[i]);
			}
			cadena2= anoepor.toString();

			sb2.append(cadena2);	
			var=2;
		}
		if(!ubicacion.getText().toString().equals("[Cualquiera]")){
			StringBuilder ubipor = new StringBuilder();
			if(var==1){

				sb2.append(":");
			}
			if(var==2){

				sb2.append(":");
			}
			sb2.append("estado;");
			try {
				textoEnviar2 = URLEncoder.encode(ubicacion.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				ubipor.append(array6[i]);
			}
			cadena2= ubipor.toString();

			sb2.append(cadena2);	
			var=3;
		}
		if(!precio.getText().toString().equals("[Cualquiera]")){
			StringBuilder prepor = new StringBuilder();
			if(var==1){

				sb2.append(":");
			}
			if(var==2){

				sb2.append(":");
			}else
				if(var==3){

					sb2.append(":");
				}
			sb2.append("rankprecio;");
			try {
				textoEnviar2 = URLEncoder.encode(precio.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				prepor.append(array6[i]);
			}
			cadena2= prepor.toString();
			sb2.append(cadena2);
			var=4;
		}
		if(!version.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb2.append(":");
			}
			if(var==2){
				sb2.append(":");
			}
			if(var==3){
				sb2.append(":");
			}
			if(var==4){
				sb2.append(":");
			}
			sb2.append("version;");
			try {
				textoEnviar2 = URLEncoder.encode(version.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb2.append(cadena2);
			var=5;
		}
		if(!transmision.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb2.append(":");
			}
			if(var==2){
				sb2.append(":");
			}
			if(var==3){
				sb2.append(":");
			}
			if(var==4){
				sb2.append(":");
			}
			if(var==5){
				sb2.append(":");
			}
			sb2.append("tipotransmision;");
			try {
				textoEnviar2 = URLEncoder.encode(transmision.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb2.append(cadena2);
			var=6;
		}
		if(!color.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb2.append(":");
			}
			if(var==2){
				sb2.append(":");
			}
			if(var==3){
				sb2.append(":");
			}
			if(var==4){
				sb2.append(":");
			}
			if(var==5){
				sb2.append(":");
			}
			if(var==6){
				sb2.append(":");
			}
			sb2.append("colorexterior;");
			try {
				textoEnviar2 = URLEncoder.encode(color.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb2.append(cadena2);
			var=7;
		}
		if(!financiamiento.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb2.append(":");
			}
			if(var==2){
				sb2.append(":");
			}
			if(var==3){
				sb2.append(":");
			}
			if(var==4){
				sb2.append(":");
			}
			if(var==5){
				sb2.append(":");
			}
			if(var==6){
				sb2.append(":");
			}
			if(var==7){
				sb2.append(":");
			}
			sb2.append("tieneplanfid;");
			try {
				textoEnviar2 = URLEncoder.encode(financiamiento.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();
			int finanid=99;
			if(cadena2.equals("Sin_Plan_de_Financiamiento")){
				finanid=0;
			}else if(cadena2.equals("Con_Plan_de_Financiamiento")){
				finanid=1;

			}
			sb2.append(finanid);
			var=8;
		}
		Log.i("URL", sb2.toString());
		return sb2.toString();
	}
	//Metodo para la año
	public String metodoano(){
		sb3= new StringBuilder();
		var=0;
		anoconcate ="http://iphone.autoplaza.com.mx/fastSearch/fastSearchIphone.aspx?isnavigator=yes&navigatorname=year&query=";
		StringBuilder sbano = new StringBuilder();
		sb3.append(anoconcate);
		if(!marca.getText().toString().equals("[Cualquiera]")){
			sb3.append("marca;");
			try {
				textoEnviar2 = URLEncoder.encode(marca.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				sbano.append(array6[i]);
			}
			cadena4= sbano.toString();

			sb3.append(cadena4);	
			var=1;
		}
		if(!modelo.getText().toString().equals("[Cualquiera]")){
			StringBuilder modsb =new StringBuilder();
			if(var==1){

				sb3.append(":");
			}
			sb3.append("modelo;");
			try {
				textoEnviar3 = URLEncoder.encode(modelo.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			char[] array7= textoEnviar3.toCharArray();
			for(int i=0; i<array7.length;i++){
				if(array7[i]=='+'){
					array7[i]='_';
				}
			}
			for(int i=0;i<array7.length;i++){
				modsb.append(array7[i]);
			}
			cadena3= modsb.toString();

			sb3.append(cadena3);	
			var=2;
		}
		if(!ubicacion.getText().toString().equals("[Cualquiera]")){
			StringBuilder ubucasb =new StringBuilder();
			if(var==1){

				sb3.append(":");
			}
			if(var==2){

				sb3.append(":");
			}
			sb3.append("estado;");
			try {
				textoEnviar2 = URLEncoder.encode(ubicacion.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				ubucasb.append(array6[i]);
			}
			cadena2= ubucasb.toString();

			sb3.append(cadena2);	
			var=3;
		}
		if(!precio.getText().toString().equals("[Cualquiera]")){
			StringBuilder preciosb =new StringBuilder();
			if(var==1){
				sb3.append(":");
			}
			if(var==2){

				sb3.append(":");
			}
			if(var==3){
				sb3.append(":");
			}
			sb3.append("rankprecio;");
			try {
				textoEnviar2 = URLEncoder.encode(precio.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				preciosb.append(array6[i]);
			}
			cadena2= preciosb.toString();
			sb3.append(cadena2);	
			var=4;
		}
		if(!version.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb3.append(":");
			}
			if(var==2){
				sb3.append(":");
			}
			if(var==3){
				sb3.append(":");
			}
			if(var==4){
				sb3.append(":");
			}
			sb3.append("version;");
			try {
				textoEnviar2 = URLEncoder.encode(version.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb3.append(cadena2);
			var=5;
		}
		if(!transmision.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb3.append(":");
			}
			if(var==2){
				sb3.append(":");
			}
			if(var==3){
				sb3.append(":");
			}
			if(var==4){
				sb3.append(":");
			}
			if(var==5){
				sb3.append(":");
			}
			sb3.append("tipotransmision;");
			try {
				textoEnviar2 = URLEncoder.encode(transmision.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb3.append(cadena2);
			var=6;
		}
		if(!color.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb3.append(":");
			}
			if(var==2){
				sb3.append(":");
			}
			if(var==3){
				sb3.append(":");
			}
			if(var==4){
				sb3.append(":");
			}
			if(var==5){
				sb3.append(":");
			}
			if(var==6){
				sb3.append(":");
			}
			sb3.append("colorexterior;");
			try {
				textoEnviar2 = URLEncoder.encode(color.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb3.append(cadena2);
			var=7;
		}
		if(!financiamiento.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb3.append(":");
			}
			if(var==2){
				sb3.append(":");
			}
			if(var==3){
				sb3.append(":");
			}
			if(var==4){
				sb3.append(":");
			}
			if(var==5){
				sb3.append(":");
			}
			if(var==6){
				sb3.append(":");
			}
			if(var==7){
				sb3.append(":");
			}
			sb3.append("tieneplanfid;");
			try {
				textoEnviar2 = URLEncoder.encode(financiamiento.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();
			int finanid=99;
			if(cadena2.equals("Sin_Plan_de_Financiamiento")){
				finanid=0;
			}else if(cadena2.equals("Con_Plan_de_Financiamiento")){
				finanid=1;

			}
			sb3.append(finanid);
			var=8;
		}
		Log.i("URL", sb3.toString());
		return sb3.toString();
	}

	//Metodo ubicacion
	public String metodoubica(){
		var=0;
		sb4= new StringBuilder();
		ubicaconcate ="http://iphone.autoplaza.com.mx/fastSearch/fastSearchIphone.aspx?isnavigator=yes&navigatorname=estado&query=";
		StringBuilder sb = new StringBuilder();
		sb4.append(ubicaconcate);
		if(!modelo.getText().toString().equals("[Cualquiera]")){
			sb4.append("modelo;");
			try {
				textoEnviar2 = URLEncoder.encode(modelo.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				sb.append(array6[i]);
			}
			cadena2= sb.toString();

			sb4.append(cadena2);	
			var=1;
		}
		if(!ano.getText().toString().equals("[Cualquiera]")){
			StringBuilder sbano = new StringBuilder();
			if(var==1){
				sb4.append(":");
			}
			sb4.append("year;");
			try {
				textoEnviar2 = URLEncoder.encode(ano.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				sbano.append(array6[i]);
			}
			cadena2= sbano.toString();
			sb4.append(cadena2);	
			var=2;
		}
		if(!marca.getText().toString().equals("[Cualquiera]")){
			StringBuilder sbmarca = new StringBuilder();
			if(var==1){
				sb4.append(":");
			}
			if(var==2){
				sb4.append(":");
			}
			sb4.append("marca;");
			try {
				textoEnviar2 = URLEncoder.encode(marca.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				sbmarca.append(array6[i]);
			}
			cadena2= sbmarca.toString();
			sb4.append(cadena2);	
			var=3;
		}
		if(!precio.getText().toString().equals("[Cualquiera]")){
			StringBuilder sbprecio = new StringBuilder();
			if(var==1){
				sb4.append(":");
			}
			if(var==2){
				sb4.append(":");
			}
			if(var==3){
				sb4.append(":");
			}
			sb4.append("rankprecio;");
			try {
				textoEnviar2 = URLEncoder.encode(precio.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				sbprecio.append(array6[i]);
			}
			cadena2= sbprecio.toString();
			sb4.append(cadena2);	
			var=4;
		}
		if(!version.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb4.append(":");
			}
			if(var==2){
				sb4.append(":");
			}
			if(var==3){
				sb4.append(":");
			}
			if(var==4){
				sb4.append(":");
			}
			sb4.append("version;");
			try {
				textoEnviar2 = URLEncoder.encode(version.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb4.append(cadena2);
			var=5;
		}
		if(!transmision.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb4.append(":");
			}
			if(var==2){
				sb4.append(":");
			}
			if(var==3){
				sb4.append(":");
			}
			if(var==4){
				sb4.append(":");
			}
			if(var==5){
				sb4.append(":");
			}
			sb4.append("tipotransmision;");
			try {
				textoEnviar2 = URLEncoder.encode(transmision.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb4.append(cadena2);
			var=6;
		}
		if(!color.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb4.append(":");
			}
			if(var==2){
				sb4.append(":");
			}
			if(var==3){
				sb4.append(":");
			}
			if(var==4){
				sb4.append(":");
			}
			if(var==5){
				sb4.append(":");
			}
			if(var==6){
				sb4.append(":");
			}
			sb4.append("colorexterior;");
			try {
				textoEnviar2 = URLEncoder.encode(color.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb4.append(cadena2);
			var=7;
		}
		if(!financiamiento.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb4.append(":");
			}
			if(var==2){
				sb4.append(":");
			}
			if(var==3){
				sb4.append(":");
			}
			if(var==4){
				sb4.append(":");
			}
			if(var==5){
				sb4.append(":");
			}
			if(var==6){
				sb4.append(":");
			}
			if(var==7){
				sb4.append(":");
			}
			sb4.append("tieneplanfid;");
			try {
				textoEnviar2 = URLEncoder.encode(financiamiento.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			int finanid=99;
			if(cadena2.equals("Sin_Plan_de_Financiamiento")){
				finanid=0;
			}else if(cadena2.equals("Con_Plan_de_Financiamiento")){
				finanid=1;

			}


			sb4.append(finanid);
			var=8;
		}
		Log.i("URL", sb4.toString());
		return sb4.toString();
	}

	//Metodo precio
	public String metodoprecio(){
		var=0;
		sb5= new StringBuilder();
		ubicaconcate ="http://iphone.autoplaza.com.mx/fastSearch/fastSearchIphone.aspx?isnavigator=yes&navigatorname=rankprecio&query=";
		StringBuilder sb = new StringBuilder();
		sb5.append(ubicaconcate);
		if(!modelo.getText().toString().equals("[Cualquiera]")){
			sb5.append("modelo;");
			try {
				textoEnviar2 = URLEncoder.encode(modelo.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				sb.append(array6[i]);
			}
			cadena2= sb.toString();
			sb5.append(cadena2);	
			var=1;
		}
		if(!ano.getText().toString().equals("[Cualquiera]")){
			StringBuilder sanob = new StringBuilder();
			if(var==1){
				sb5.append(":");
			}
			sb5.append("year;");
			try {
				textoEnviar2 = URLEncoder.encode(ano.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				sanob.append(array6[i]);
			}
			cadena2= sanob.toString();
			sb5.append(cadena2);	
			var=2;
		}
		if(!ubicacion.getText().toString().equals("[Cualquiera]")){
			StringBuilder subicacionb = new StringBuilder();
			if(var==1){
				sb5.append(":");
			}
			if(var==2){
				sb5.append(":");
			}
			sb5.append("estado;");
			try {
				textoEnviar2 = URLEncoder.encode(ubicacion.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				subicacionb.append(array6[i]);
			}
			cadena2= subicacionb.toString();

			sb5.append(cadena2);	
			var=3;
		}
		if(!marca.getText().toString().equals("[Cualquiera]")){
			StringBuilder smarcab = new StringBuilder();
			if(var==1){
				sb5.append(":");
			}
			if(var==2){
				sb5.append(":");
			}
			if(var==3){
				sb5.append(":");
			}
			sb5.append("marca;");
			try {
				textoEnviar2 = URLEncoder.encode(marca.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				smarcab.append(array6[i]);
			}
			cadena2= smarcab.toString();

			sb5.append(cadena2);
			var=4;
		}
		if(!version.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb5.append(":");
			}
			if(var==2){
				sb5.append(":");
			}
			if(var==3){
				sb5.append(":");
			}
			if(var==4){
				sb5.append(":");
			}
			sb5.append("version;");
			try {
				textoEnviar2 = URLEncoder.encode(version.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb5.append(cadena2);
			var=5;
		}
		if(!transmision.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb5.append(":");
			}
			if(var==2){
				sb5.append(":");
			}
			if(var==3){
				sb5.append(":");
			}
			if(var==4){
				sb5.append(":");
			}
			if(var==5){
				sb5.append(":");
			}
			sb5.append("tipotransmision;");
			try {
				textoEnviar2 = URLEncoder.encode(transmision.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb5.append(cadena2);
			var=6;
		}
		if(!color.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb5.append(":");
			}
			if(var==2){
				sb5.append(":");
			}
			if(var==3){
				sb5.append(":");
			}
			if(var==4){
				sb5.append(":");
			}
			if(var==5){
				sb5.append(":");
			}
			if(var==6){
				sb5.append(":");
			}
			sb5.append("colorexterior;");
			try {
				textoEnviar2 = URLEncoder.encode(color.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb5.append(cadena2);
			var=7;
		}
		if(!financiamiento.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb5.append(":");
			}
			if(var==2){
				sb5.append(":");
			}
			if(var==3){
				sb5.append(":");
			}
			if(var==4){
				sb5.append(":");
			}
			if(var==5){
				sb5.append(":");
			}
			if(var==6){
				sb5.append(":");
			}
			if(var==7){
				sb5.append(":");
			}
			sb5.append("tieneplanfid;");
			try {
				textoEnviar2 = URLEncoder.encode(financiamiento.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			int finanid=99;
			if(cadena2.equals("Sin_Plan_de_Financiamiento")){
				finanid=0;
			}else if(cadena2.equals("Con_Plan_de_Financiamiento")){
				finanid=1;

			}


			sb5.append(finanid);
			var=8;
		}

		Log.i("URL", sb5.toString());
		return sb5.toString();
	}


	//Metodo version
	public String metodoversion(){
		var=0;
		sb6= new StringBuilder();
		ubicaconcate ="http://iphone.autoplaza.com.mx/fastSearch/fastSearchIphone.aspx?isnavigator=yes&navigatorname=version&query=";
		StringBuilder sb = new StringBuilder();
		sb6.append(ubicaconcate);
		if(!modelo.getText().toString().equals("[Cualquiera]")){
			sb6.append("modelo;");
			try {
				textoEnviar2 = URLEncoder.encode(modelo.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				sb.append(array6[i]);
			}
			cadena2= sb.toString();
			sb6.append(cadena2);	
			var=1;
		}
		if(!ano.getText().toString().equals("[Cualquiera]")){
			StringBuilder sanob = new StringBuilder();
			if(var==1){
				sb6.append(":");
			}
			sb6.append("year;");
			try {
				textoEnviar2 = URLEncoder.encode(ano.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				sanob.append(array6[i]);
			}
			cadena2= sanob.toString();
			sb6.append(cadena2);	
			var=2;
		}
		if(!ubicacion.getText().toString().equals("[Cualquiera]")){
			StringBuilder subicacionb = new StringBuilder();
			if(var==1){
				sb6.append(":");
			}
			if(var==2){
				sb6.append(":");
			}
			sb6.append("estado;");
			try {
				textoEnviar2 = URLEncoder.encode(ubicacion.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				subicacionb.append(array6[i]);
			}
			cadena2= subicacionb.toString();

			sb6.append(cadena2);	
			var=3;
		}
		if(!marca.getText().toString().equals("[Cualquiera]")){
			StringBuilder smarcab = new StringBuilder();
			if(var==1){
				sb6.append(":");
			}
			if(var==2){
				sb6.append(":");
			}
			if(var==3){
				sb6.append(":");
			}
			sb6.append("marca;");
			try {
				textoEnviar2 = URLEncoder.encode(marca.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				smarcab.append(array6[i]);
			}
			cadena2= smarcab.toString();

			sb6.append(cadena2);
			var=4;
		}
		if(!precio.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb6.append(":");
			}
			if(var==2){
				sb6.append(":");
			}
			if(var==3){
				sb6.append(":");
			}
			if(var==4){
				sb6.append(":");
			}
			sb6.append("rankprecio;");
			try {
				textoEnviar2 = URLEncoder.encode(precio.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb6.append(cadena2);
			var=5;
		}
		if(!transmision.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb6.append(":");
			}
			if(var==2){
				sb6.append(":");
			}
			if(var==3){
				sb6.append(":");
			}
			if(var==4){
				sb6.append(":");
			}
			if(var==5){
				sb6.append(":");
			}
			sb6.append("tipotransmision;");
			try {
				textoEnviar2 = URLEncoder.encode(transmision.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb6.append(cadena2);
			var=6;
		}
		if(!color.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb6.append(":");
			}
			if(var==2){
				sb6.append(":");
			}
			if(var==3){
				sb6.append(":");
			}
			if(var==4){
				sb6.append(":");
			}
			if(var==5){
				sb6.append(":");
			}
			if(var==6){
				sb6.append(":");
			}
			sb6.append("colorexterior;");
			try {
				textoEnviar2 = URLEncoder.encode(color.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb6.append(cadena2);
			var=7;
		}
		if(!financiamiento.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb6.append(":");
			}
			if(var==2){
				sb6.append(":");
			}
			if(var==3){
				sb6.append(":");
			}
			if(var==4){
				sb6.append(":");
			}
			if(var==5){
				sb6.append(":");
			}
			if(var==6){
				sb6.append(":");
			}
			if(var==7){
				sb6.append(":");
			}
			sb6.append("tieneplanfid;");
			try {
				textoEnviar2 = URLEncoder.encode(financiamiento.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			int finanid=99;
			if(cadena2.equals("Sin_Plan_de_Financiamiento")){
				finanid=0;
			}else if(cadena2.equals("Con_Plan_de_Financiamiento")){
				finanid=1;

			}


			sb6.append(finanid);
			var=8;
		}

		Log.i("URL_sb6", sb6.toString());
		return sb6.toString();
	}



	protected String metodotransmision() {
		var=0;
		sb7= new StringBuilder();
		ubicaconcate ="http://iphone.autoplaza.com.mx/fastSearch/fastSearchIphone.aspx?isnavigator=yes&navigatorname=transmision&query=";
		StringBuilder sb = new StringBuilder();
		sb7.append(ubicaconcate);
		if(!modelo.getText().toString().equals("[Cualquiera]")){
			sb7.append("modelo;");
			try {
				textoEnviar2 = URLEncoder.encode(modelo.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				sb.append(array6[i]);
			}
			cadena2= sb.toString();
			sb7.append(cadena2);	
			var=1;
		}
		if(!ano.getText().toString().equals("[Cualquiera]")){
			StringBuilder sanob = new StringBuilder();
			if(var==1){
				sb7.append(":");
			}
			sb7.append("year;");
			try {
				textoEnviar2 = URLEncoder.encode(ano.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				sanob.append(array6[i]);
			}
			cadena2= sanob.toString();
			sb7.append(cadena2);	
			var=2;
		}
		if(!ubicacion.getText().toString().equals("[Cualquiera]")){
			StringBuilder subicacionb = new StringBuilder();
			if(var==1){
				sb7.append(":");
			}
			if(var==2){
				sb7.append(":");
			}
			sb7.append("estado;");
			try {
				textoEnviar2 = URLEncoder.encode(ubicacion.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				subicacionb.append(array6[i]);
			}
			cadena2= subicacionb.toString();

			sb7.append(cadena2);	
			var=3;
		}
		if(!marca.getText().toString().equals("[Cualquiera]")){
			StringBuilder smarcab = new StringBuilder();
			if(var==1){
				sb7.append(":");
			}
			if(var==2){
				sb7.append(":");
			}
			if(var==3){
				sb7.append(":");
			}
			sb7.append("marca;");
			try {
				textoEnviar2 = URLEncoder.encode(marca.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				smarcab.append(array6[i]);
			}
			cadena2= smarcab.toString();

			sb7.append(cadena2);
			var=4;
		}
		if(!precio.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb7.append(":");
			}
			if(var==2){
				sb7.append(":");
			}
			if(var==3){
				sb7.append(":");
			}
			if(var==4){
				sb7.append(":");
			}
			sb7.append("rankprecio;");
			try {
				textoEnviar2 = URLEncoder.encode(precio.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb7.append(cadena2);
			var=5;
		}
		if(!color.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb7.append(":");
			}
			if(var==2){
				sb7.append(":");
			}
			if(var==3){
				sb7.append(":");
			}
			if(var==4){
				sb7.append(":");
			}
			if(var==5){
				sb7.append(":");
			}
			sb7.append("colorexterior;");
			try {
				textoEnviar2 = URLEncoder.encode(color.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb7.append(cadena2);
			var=6;
		}
		if(!financiamiento.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb7.append(":");
			}
			if(var==2){
				sb7.append(":");
			}
			if(var==3){
				sb7.append(":");
			}
			if(var==4){
				sb7.append(":");
			}
			if(var==5){
				sb7.append(":");
			}
			if(var==6){
				sb7.append(":");
			}
			sb7.append("tieneplanfid;");
			try {
				textoEnviar2 = URLEncoder.encode(financiamiento.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			int finanid=99;
			if(cadena2.equals("Sin_Plan_de_Financiamiento")){
				finanid=0;
			}else if(cadena2.equals("Con_Plan_de_Financiamiento")){
				finanid=1;

			}


			sb7.append(finanid);
			var=7;
		}

		Log.i("URL_sb7", sb7.toString());
		return sb7.toString();
	}


	protected String metodocolor() {
		var=0;
		sb8= new StringBuilder();
		ubicaconcate ="http://iphone.autoplaza.com.mx/fastSearch/fastSearchIphone.aspx?isnavigator=yes&navigatorname=color&query=";
		StringBuilder sb = new StringBuilder();
		sb8.append(ubicaconcate);
		if(!modelo.getText().toString().equals("[Cualquiera]")){
			sb8.append("modelo;");
			try {
				textoEnviar2 = URLEncoder.encode(modelo.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				sb.append(array6[i]);
			}
			cadena2= sb.toString();
			sb8.append(cadena2);	
			var=1;
		}
		if(!ano.getText().toString().equals("[Cualquiera]")){
			StringBuilder sanob = new StringBuilder();
			if(var==1){
				sb8.append(":");
			}
			sb8.append("year;");
			try {
				textoEnviar2 = URLEncoder.encode(ano.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				sanob.append(array6[i]);
			}
			cadena2= sanob.toString();
			sb8.append(cadena2);	
			var=2;
		}
		if(!ubicacion.getText().toString().equals("[Cualquiera]")){
			StringBuilder subicacionb = new StringBuilder();
			if(var==1){
				sb8.append(":");
			}
			if(var==2){
				sb8.append(":");
			}
			sb8.append("estado;");
			try {
				textoEnviar2 = URLEncoder.encode(ubicacion.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				subicacionb.append(array6[i]);
			}
			cadena2= subicacionb.toString();

			sb8.append(cadena2);	
			var=3;
		}
		if(!marca.getText().toString().equals("[Cualquiera]")){
			StringBuilder smarcab = new StringBuilder();
			if(var==1){
				sb8.append(":");
			}
			if(var==2){
				sb8.append(":");
			}
			if(var==3){
				sb8.append(":");
			}
			sb8.append("marca;");
			try {
				textoEnviar2 = URLEncoder.encode(marca.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				smarcab.append(array6[i]);
			}
			cadena2= smarcab.toString();

			sb8.append(cadena2);
			var=4;
		}
		if(!precio.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb8.append(":");
			}
			if(var==2){
				sb8.append(":");
			}
			if(var==3){
				sb8.append(":");
			}
			if(var==4){
				sb8.append(":");
			}
			sb8.append("rankprecio;");
			try {
				textoEnviar2 = URLEncoder.encode(precio.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb8.append(cadena2);
			var=5;
		}
		if(!transmision.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb8.append(":");
			}
			if(var==2){
				sb8.append(":");
			}
			if(var==3){
				sb8.append(":");
			}
			if(var==4){
				sb8.append(":");
			}
			if(var==5){
				sb8.append(":");
			}
			sb8.append("tipotransmision;");
			try {
				textoEnviar2 = URLEncoder.encode(transmision.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb8.append(cadena2);
			var=6;
		}
		if(!financiamiento.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb8.append(":");
			}
			if(var==2){
				sb8.append(":");
			}
			if(var==3){
				sb8.append(":");
			}
			if(var==4){
				sb8.append(":");
			}
			if(var==5){
				sb8.append(":");
			}
			if(var==6){
				sb8.append(":");
			}
			sb8.append("tieneplanfid;");
			try {
				textoEnviar2 = URLEncoder.encode(financiamiento.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			int finanid=99;
			if(cadena2.equals("Sin_Plan_de_Financiamiento")){
				finanid=0;
			}else if(cadena2.equals("Con_Plan_de_Financiamiento")){
				finanid=1;

			}


			sb8.append(finanid);
			var=8;
		}
		Log.i("URL_sb6", sb8.toString());
		return sb8.toString();
	}

	protected String metodofinanciamiento() {
		var=0;
		sb10= new StringBuilder();
		ubicaconcate ="http://iphone.autoplaza.com.mx/fastSearch/fastSearchIphone.aspx?isnavigator=yes&navigatorname=finan&query=";
		StringBuilder sb = new StringBuilder();
		sb10.append(ubicaconcate);
		if(!modelo.getText().toString().equals("[Cualquiera]")){
			sb10.append("modelo;");
			try {
				textoEnviar2 = URLEncoder.encode(modelo.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				sb.append(array6[i]);
			}
			cadena2= sb.toString();
			sb10.append(cadena2);	
			var=1;
		}
		if(!ano.getText().toString().equals("[Cualquiera]")){
			StringBuilder sanob = new StringBuilder();
			if(var==1){
				sb10.append(":");
			}
			sb10.append("year;");
			try {
				textoEnviar2 = URLEncoder.encode(ano.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				sanob.append(array6[i]);
			}
			cadena2= sanob.toString();
			sb10.append(cadena2);	
			var=2;
		}
		if(!ubicacion.getText().toString().equals("[Cualquiera]")){
			StringBuilder subicacionb = new StringBuilder();
			if(var==1){
				sb10.append(":");
			}
			if(var==2){
				sb10.append(":");
			}
			sb10.append("estado;");
			try {
				textoEnviar2 = URLEncoder.encode(ubicacion.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				subicacionb.append(array6[i]);
			}
			cadena2= subicacionb.toString();

			sb10.append(cadena2);	
			var=3;
		}
		if(!marca.getText().toString().equals("[Cualquiera]")){
			StringBuilder smarcab = new StringBuilder();
			if(var==1){
				sb10.append(":");
			}
			if(var==2){
				sb10.append(":");
			}
			if(var==3){
				sb10.append(":");
			}
			sb10.append("marca;");
			try {
				textoEnviar2 = URLEncoder.encode(marca.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				smarcab.append(array6[i]);
			}
			cadena2= smarcab.toString();

			sb10.append(cadena2);
			var=4;
		}
		if(!precio.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb10.append(":");
			}
			if(var==2){
				sb10.append(":");
			}
			if(var==3){
				sb10.append(":");
			}
			if(var==4){
				sb10.append(":");
			}
			sb10.append("rankprecio;");
			try {
				textoEnviar2 = URLEncoder.encode(precio.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb10.append(cadena2);
			var=5;
		}
		if(!transmision.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb10.append(":");
			}
			if(var==2){
				sb10.append(":");
			}
			if(var==3){
				sb10.append(":");
			}
			if(var==4){
				sb10.append(":");
			}
			if(var==5){
				sb10.append(":");
			}
			sb10.append("tipotransmision;");
			try {
				textoEnviar2 = URLEncoder.encode(transmision.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb10.append(cadena2);
			var=6;
		}
		if(!color.getText().toString().equals("[Cualquiera]")){
			StringBuilder spreciob = new StringBuilder();
			if(var==1){
				sb10.append(":");
			}
			if(var==2){
				sb10.append(":");
			}
			if(var==3){
				sb10.append(":");
			}
			if(var==4){
				sb10.append(":");
			}
			if(var==5){
				sb10.append(":");
			}
			if(var==6){
				sb10.append(":");
			}
			sb10.append("colorexterior;");
			try {
				textoEnviar2 = URLEncoder.encode(color.getText().toString(), "utf-8");
			} catch (UnsupportedEncodingException e1) {
				e1.printStackTrace();
			}
			char[] array6= textoEnviar2.toCharArray();
			for(int i=0; i<array6.length;i++){
				if(array6[i]=='+'){
					array6[i]='_';
				}
			}
			for(int i=0;i<array6.length;i++){
				spreciob.append(array6[i]);
			}
			cadena2= spreciob.toString();

			sb10.append(cadena2);
			var=7;
		}
		Log.i("URL_sb10", sb10.toString());
		return sb10.toString();
	}

}
